$(document).ready(function () {

    var app = $.sammy('#Main', function (context) {
        this.get('#/PasswordReset', function () {
            LoadResetPassword();
        });
        this.get('#/account_confirm', function () {
            var token = this.params['tk'];
            LoadConfirmActivation(token);
        });
        this.get('#/account_passwordreset', function () {
            var token = this.params['tk'];
            LoadResetPasswordAction(token);
        });
    });




    $('#UserProfile').click(function (event) {
        $.ajax({
            url: './UserProfile/UserProfileGrid/',
            cache: false,
            success: function (html) {
                $('#Main').html(html);
            },
            error: function (xhr, ajaxOptions, thrownError) {
                alert('Status: ' + xhr.status + ' Response Text: ' + xhr.responseText);
            }
        });
        $.ajax({
            url: './UserProfile/UserProfileAccordion/',
            cache: false,
            success: function (html) {
                $('#Nav').html(html);
            },
            error: function (xhr, ajaxOptions, thrownError) {
                alert('Status: ' + xhr.status + ' Response Text: ' + xhr.responseText);
            }
        });
        return false
    });
    $('#Application').click(function (event) {
        $.ajax({
            url: './Application/ApplicationGrid/',
            cache: false,
            success: function (html) {
                $('#Main').html(html);
            },
            error: function (xhr, ajaxOptions, thrownError) {
                alert('Status: ' + xhr.status + ' Response Text: ' + xhr.responseText);
            }
        });
        $.ajax({
            url: './Application/ApplicationAccordion/',
            cache: false,
            success: function (html) {
                $('#Nav').html(html);
            },
            error: function (xhr, ajaxOptions, thrownError) {
                alert('Status: ' + xhr.status + ' Response Text: ' + xhr.responseText);
            }
        });
        return false
    });
    $('#PasswordQuestion').click(function (event) {
        $.ajax({
            url: './PasswordQuestion/PasswordQuestionGrid/',
            cache: false,
            success: function (html) {
                $('#Main').html(html);
            },
            error: function (xhr, ajaxOptions, thrownError) {
                alert('Status: ' + xhr.status + ' Response Text: ' + xhr.responseText);
            }
        });
        $.ajax({
            url: './PasswordQuestion/PasswordQuestionAccordion/',
            cache: false,
            success: function (html) {
                $('#Nav').html(html);
            },
            error: function (xhr, ajaxOptions, thrownError) {
                alert('Status: ' + xhr.status + ' Response Text: ' + xhr.responseText);
            }
        });
        return false
    });
    $('#DomainName').click(function (event) {
        $.ajax({
            url: './DomainName/DomainNameGrid/',
            cache: false,
            success: function (html) {
                $('#Main').html(html);
            },
            error: function (xhr, ajaxOptions, thrownError) {
                alert('Status: ' + xhr.status + ' Response Text: ' + xhr.responseText);
            }
        });
        $.ajax({
            url: './DomainName/DomainNameAccordion/',
            cache: false,
            success: function (html) {
                $('#Nav').html(html);
            },
            error: function (xhr, ajaxOptions, thrownError) {
                alert('Status: ' + xhr.status + ' Response Text: ' + xhr.responseText);
            }
        });
        return false
    });

    $('#Admin').click(function (event) {
        $.ajax({
            url: './Admin/AdminAccordion/',
            cache: false,
            success: function (html) {
                $('#Nav').html(html);
                $('#Nav').show();
                return false;
            },
            error: function (xhr, ajaxOptions, thrownError) {
                alert("Status: " + xhr.status + " Response Text: " + xhr.responseText);

            }
        });
        return false;
    });

    $('#registerLink').click(function (event) {
        $.ajax({
            url: './Account/Register/',
            cache: false,
            success: function (html) {
                $('#Main').html(html);
                $('#Nav').hide();
                return false;
            },
            error: function (xhr, ajaxOptions, thrownError) {
                alert("Status: " + xhr.status + " Response Text: " + xhr.responseText);

            }
        });
        return false;
    });

    $('#loginLink').click(function (event) {
        $.ajax({
            url: './Account/Login/',
            cache: false,
            success: function (html) {
                $('#Main').html(html);
                $('#Nav').hide();
                return false;
            },
            error: function (xhr, ajaxOptions, thrownError) {
                alert("Status: " + xhr.status + " Response Text: " + xhr.responseText);

            }
        });
        return false;
    });

    //$('#ResetPass').click(function (event) {
    //    return LoadResetPassword();
    //});

    $(function () { app.run('#/'); });

});

function LoadConfirmActivation(token) {
    
    
    $.ajax({
        url: '/Account/Confirm/',
        cache: false,
        data: {tk:token},
        success: function (html) {
            $('#Main').html(html);
            return false;
        },
        error: function (xhr, ajaxOptions, thrownError) {
            alert("Status: " + xhr.status + " Response Text: " + xhr.responseText);

        }
    });
    return false;
}

function LoadResetPassword() {
    $.ajax({
        url: '/Account/PasswordResetRequest/',
        cache: false,
        success: function (html) {
            $('#Main').html(html);
            $('#Nav').hide();
            return false;
        },
        error: function (xhr, ajaxOptions, thrownError) {
            alert("Status: " + xhr.status + " Response Text: " + xhr.responseText);

        }
    });
    return false;
}
function LoadResetPasswordAction(token) {
    $.ajax({
        url: '/Account/PasswordReset/',
        cache: false,
        data:{tk:token},
        success: function (html) {
            $('#Main').html(html);
            return false;
        },
        error: function (xhr, ajaxOptions, thrownError) {
            alert("Status: " + xhr.status + " Response Text: " + xhr.responseText);

        }
    });
    return false;
}
		
		
		
		
			
			